<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">加载中。。</button>
    <script>
        var a = 1;

        function test() {
            // this指向window 严格模式下指向undefined
            console.log(this);
            console.log(this.a);
        }
        test()
        var obj = {
            a: 'obj',
            test: function() {
                // this指向对象， 实例对象
                console.log(this);
                console.log(this.a);
            }
        }
        obj.test()

        function Test(a) {
            this.a = a;
            // 指向实例对象
            console.log(this);
            console.log(this.a);
        }
        new Test('对象');

        var oBtn = document.getElementById('btn')
        oBtn.onclick = function() {

        }
    </script>
</body>

</html>